home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13155 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  46 lines

  1. Newsgroups: comp.lang.c++
  2. Path: novice.uwaterloo.ca!a2patel
  3. From: a2patel@novice.uwaterloo.ca (Aashish-Kaski-Ashman-Patel)
  4. Subject: Newbie Ques: Templates and C++
  5. Sender: news@novice.uwaterloo.ca (Mr. News)
  6. Message-ID: <DoqLy6.H7q@novice.uwaterloo.ca>
  7. Date: Sat, 23 Mar 1996 20:22:54 GMT
  8. Nntp-Posting-Host: novice.uwaterloo.ca
  9. Organization: University of Waterloo
  10.  
  11. Ok.. Here is what I am trying to do:
  12. 1) 
  13. Have a class called Dictionary that depends on two other classes ( determined
  14. at compile time ).
  15. ie. #ifdef HASH
  16.        class Dictionary Hash-Table;
  17.     #else-if BST
  18.        class Dictionary Bst;
  19.     #endif
  20.  
  21. Now Hashtable is a template class .. defined
  22. template <class typeofwhatever> 
  23. class HashTable
  24. {
  25.   //whatever;
  26. }
  27. The class definitions are in a header file, and the code in a normal source 
  28. file. The problem is that when I try to compile the source, I get errors.
  29. I believe that this is just a syntax probelm.. The error I get is 
  30. HashTable::HashTable() cannot be defined in the same scope as class template.
  31.  
  32. Furthermore, are the ifdefs above correct... and can I have the following
  33. statement..
  34. class Dictionary HashTable<int>;
  35. I have tried these and have gotten errors... I do believe that this is possible
  36. but I don't have the syntax correct..
  37.  
  38. any help is appreciated..
  39. Thanx.
  40.  
  41. -- 
  42. ------------------- Aashish Patel. --------------- 
  43. Electrical Engineering, Univesity Of Waterloo.
  44. mailto: a2patel@novice.uwaterloo.ca
  45. http://www.io.org/~cyourth/aashish.htm (old)
  46.